package vessels 
{
	import constants.Events;
	import flash.events.MouseEvent;
	import logics.CustomEvent;
	import points.CollidePoint;
	/**
	 * ...
	 * @author parasitic
	 */
	public class Vessel extends DrawVessel 
	{
		protected var motionTween:Tween;
		protected var speed:Number = 10;
		
		public function move(dx:Number, dy:Number):void
		{
			var p:Object;
			p = { x:{start:this.x, end:this.x + dx, steps:speed}, y:{ start:this.y, end:this.y + dy, steps:speed }};
			motionTween = new Tween(this, p, Tween.circleInOut);
			motionTween.start();
		}
		
		public function rotateTarget(other:CollidePoint):void
		{	
			var angle:Number = (180/Math.PI) *  Math.atan2(get_y() - other.get_y(), get_x()- other.get_x());
			this.rotation = -(angle);
		}
		
		public function mousedown_handler(e:MouseEvent):void
		{
			dispatchEvent( new CustomEvent(Events.UNIT_SELECTED, this));
		}
		
		public function Vessel(n:Number, lColor:uint, fColor:uint) 
		{
			draw(n, 4, lColor, fColor, .4, .5);
			setRadius(n);
			
			addEventListener(MouseEvent.MOUSE_DOWN, mousedown_handler);
		}
		
	}

}